import{Mongoose,Schema,Model,Document} from 'mongoose';
import { BaseDao} from './BaseDao';
import {UsersDao} from './UsersDao';
import{ User} from '../models/User';
import {Token} from '../models/Token';
export class TokensDao extends BaseDao
{
  tokenModel:Model<any>;
  constructor(){
    super();
    this.tokenModel = this.dbManager.getModel("mToken");
  }
  add(userId:string,callback:Function)
  {
    var token = new Token();
    token.user = userId;
    var token_ = new this.tokenModel(token);
    token_.save(callback);
  }
  get(tokenStr:string,callback:Function)
  {
    this.tokenModel.findOne({_id:tokenStr}).populate('user').exec(callback);
  }
}
